/*
 * @Descripttion: 
 * @version: 
 * @Author: 玄绮 <shijiahansi@qq.com>
 * @Date: 2021-10-31 18:26:23
 * @LastEditTime: 2021-11-08 08:57:47
 * @LastEditors: VS Code
 */
#include <REG52.H>
#include "51_type.h"
#include "commom.h"

#define LEDDZ_COL_PORT P0 //点阵列控制端口

//定义74HC595控制管脚
sbit SRCLK1 = const_P3 ^ 6; //移位寄存器时钟输入
sbit RCLK1 = const_P3 ^ 5;  //存储寄存器时钟输入
sbit SER = const_P3 ^ 4;    //串行数据输入


// uint8 gled_row[] = {0x08, 0x10, 0xA7, 0xF8, 0xF8, 0xA7, 0x10, 0x08};

uint8 gled_row2[] = {0x38, 0x7C, 0x7E, 0x3F, 0x3F, 0x7E, 0x7C, 0x38};

void leddz_init()
{
    P2 = ~0;
    hc595_write_data(0x00);
    LEDDZ_COL_PORT = ~(0x00);
}

void leddz_desplay()
{
    uint8 i = 0, j = 0;

    P2 = ~0;

    for (i = 0; i < 8; i++) //循环8次扫描8行、列
    {
        hc595_write_data(0x80 >> i);
        for (j = 0; j < 8; j++)
        {
            LEDDZ_COL_PORT = ~(0xff);
            delay_1ms(1);
        }
    }
    leddz_init();
}

void leddz_outImg(uint8 row[8])
{
    uint8 i = 0, j = 0;

    P2 = ~0;

    for (i = 0; i < 8; i++) //循环8次扫描8行、列
    {
        LEDDZ_COL_PORT = ~(0x80 >> i); //传送列选数据
        hc595_write_data(row[i]);
        delay_10us(10000);         //延时一段时间，等待显示稳定
        hc595_write_data(0x00); //消影
    }
}

// void leddz_outImg_col(uint8 col[8])
// {
//     uint8 i = 0, j = 0;
//     P2 = ~0;

//     for (i = 0; i < 8; i++) //循环8次扫描8行、列
//     {
//         hc595_write_data(0x80 >> i);
//         LEDDZ_COL_PORT = ~col[i];
//         delay_10us(25);         //延时一段时间，等待显示稳定
//         hc595_write_data(0x00); //消影
//     }
// }